/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 *
 * @author Antoine
 * A formal concept is a concept from the ontology to which we give a name and which will be used to make the correspondence with the form fields
 */
public class FormalConcept {

    public static int idLastCreated=0;
    
    private int id;
    private String name;
    private Ontology ontologyAssociated;
    private Concept ontologyConcept;
    private List<Correspondence> correspondences = new ArrayList<Correspondence>();

    public FormalConcept() {
        super();
        this.id = Commun.IncrementId(FormalConcept.idLastCreated,1);
    }

    public FormalConcept(String name) {
        this();
        this.name = name;
    }
    
    public void CreateCorrespondence(Correspondence correspondence)
    {
        correspondences.add(correspondence);
    }
    
    public void RemoveCorrespondence(Correspondence correspondence)
    {
        correspondences.remove(correspondence);
    }

    public void setName(String name) {
        this.name = name;
    }

    public Concept getOntologyConcept() {
        return ontologyConcept;
    }

    public void setOntologyConcept(Concept concept) {
        this.ontologyConcept = concept;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }
    
    public int getNumberOfCorrespondences() {
        return correspondences.size();
    }
    
    public void addCorrespondence(FormField field, Attribute att) {
        correspondences.add(new Correspondence(field,this,att) );
    }

    public List<Correspondence> getCorrespondences() {
        return correspondences;
    }

    public void setCorrespondences(List<Correspondence> correspondences) {
        this.correspondences = correspondences;
    }
    
     public Ontology getOntologyAssociated() {
        return ontologyAssociated;
    }

    public void setOntologyAssociated(Ontology ontologyAssociated) {
        this.ontologyAssociated = ontologyAssociated;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final FormalConcept other = (FormalConcept) obj;
        if (!Objects.equals(this.name, other.name)) {
            return false;
        }
        return true;
    }
    
    
}
